Test Failed
Push — master ( 41e89b...cfe199 )
by ANTHONIUS
04:45 queued 12s
created

MyDocument   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
c 0
b 0
f 0
dl 0
loc 18
rs 10
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A render 0 16 1
1
import React from "react";
2
import Document, {Html, Head, Main, NextScript} from "next/document";
3
import {ServerStyleSheets} from "@material-ui/core";
4
import theme from '../src/theme';
5
6
export default class MyDocument extends Document {
7
  render(){
8
    return (
9
      <Html lang="en">
10
        <Head>
11
          {/* PWA primary color */}
12
          <meta name="theme-color" content={theme.palette.primary.main} />
13
          <link
14
            rel="stylesheet"
15
            href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
16
          />
17
        </Head>
18
        <body>
19
        <Main />
20
        <NextScript />
21
        </body>
22
      </Html>
23
    );
24
  }
25
}
26
27
MyDocument.getInitialProps = async (ctx) => {
28
  const sheets = new ServerStyleSheets();
29
  const originalRenderPage = ctx.renderPage;
30
  ctx.renderPage = () =>
31
    originalRenderPage({
32
      enhanceApp: (App) => (props) => sheets.collect(<App {...props} />),
33
    });
34
35
  const initialProps = await Document.getInitialProps(ctx);
36
37
  return {
38
    ...initialProps,
39
    // Styles fragment is rendered after the app and page rendering finish.
40
    styles: [...React.Children.toArray(initialProps.styles), sheets.getStyleElement()],
41
  };
42
}
43